package com.zll.feign;

import com.zll.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component // 交给spring管理
public class UserServiceFallbackFactory implements FallbackFactory<UserService> {


    @Override
    public UserService create(Throwable throwable) {
        throwable.printStackTrace();
        return new UserService() {
            @Override
            public User getUser(Long id) {
                return new User(-1L,"熔断被触发了","当前服务不可用，请稍后重试！");
            }
        };
    }
}
